<%@ page language="java" import="java.util.*,java.sql.*,java.lang.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
  </head>
  
  <body>
   <span>
   所有年级信息为：
   <br>
   
  <%    try {
		 Class.forName("com.mysql.jdbc.Driver");
		} catch (ClassNotFoundException e) {
		// TODO Auto-generated catch block
		 e.printStackTrace();
		}
        Connection cnn = null;
		ResultSet rs01 = null;
		PreparedStatement stmt = null;
		int i = 0;
		
		try {
			cnn = (Connection) DriverManager.getConnection(
		"jdbc:mysql://localhost:3306/epet", "epetadmin", "0000");
			//cnn = DBUtil.getConnection();
			String ss = "SELECT gname FROM grade";

			stmt = cnn.prepareStatement(ss);
			

			rs01 = stmt.executeQuery();
			while (rs01.next()) {
				
				String name = rs01.getString("gname");
				out.print(name+"<br>");
				
			}

			rs01.close();
			stmt.close();
			cnn.close();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
  
  
  
   %>
   
   </span>
  </body>
</html>
